Skip to content

Calculate the union of two maps

Use the map function to combine array1 and array2 into the JSON format, in which array1 is the object key and array2 is the object value. Then, use the map_concat function to calculate the union of the two maps to obtain a new object.

SQL
|
SELECT
  map_concat(
    map(ARRAY [1,2], ARRAY [3,4]),
    map(ARRAY [5,2], ARRAY [7,8])
  ) as "Union of two maps"